Adjustment of a sleep duration for a process based on an expected time for securing a spinlock

ABSTRACT

A computational device maintains a spinlock for exclusive access of a resource by a process of a plurality of processes. In response to determining by the process that a turn for securing the spinlock has not arrived for the process, a sleep duration is determined for the process, prior to making a next attempt to secure the spinlock.

CROSS-REFERENCE TO RELATED APPLICATION

This application is a continuation of U.S. patent application Ser. No.15/332,394, filed Oct. 24, 2016, which application is incorporatedherein by reference in its entirety.

BACKGROUND 1. Field

Embodiments relate to an adjustment of a sleep duration for a processbased on an expected time for securing a spinlock.

2. Background

A computational device may include a plurality of processors and form amultiprocessing system. The plurality of processors may be referred toas cores, where each core may comprise a central processing unit (CPU).Processes or threads may be executed in parallel in the plurality ofcores of the computational device. Both processes and threads areindependent sequences of execution. The difference is that threads (ofthe same process) run in a shared memory space, while processes run inseparate memory spaces.

A lock is a synchronization mechanism for enforcing limits on access toa resource in an environment where there are many threads of execution.A lock is designed to enforce a mutual exclusion concurrency controlpolicy. Some locking mechanisms block the execution of the thread (orprocess) requesting the lock until the thread is allowed to access thelocked resource. With a spinlock, the thread simply waits (“spins”)until the lock becomes available.

A ticket lock is a type of spinlock that uses “tickets” to control whichthread of execution (or process) is allowed to enter a critical section.A ticket lock is a first in first out (FIFO) queue-based mechanism.Threads may be assigned sequentially numbered tickets as they arecreated. A thread is permitted to enter the critical section when itsticket number is being served, where the critical section is a part of aprogram where a protected shared resource is accessed, and where thecritical section cannot be executed by more than one thread at the sametime.

SUMMARY OF THE PREFERRED EMBODIMENTS

Provided are a method, a system, and a computer program product in whicha computational device maintains a spinlock for exclusive access of aresource by a process of a plurality of processes. In response todetermining by the process that a turn for securing the spinlock has notarrived for the process, a sleep duration is determined for the process,prior to making a next attempt to secure the spinlock.

In certain embodiments, the plurality of processes are assignedsequential ticket numbers, wherein the plurality of processes secure thespinlock in sequence, based on the sequentially assigned ticket numbers.

In further embodiments, the sleep duration for the process is based onwhen the process is likely to secure the spinlock based on a ticketnumber of the process.

In additional embodiments, the process undergoes spinning for apredetermined number of processor cycles and a determination is made ofhow many tickets have been processed during the predetermined number ofprocessor cycles. A time duration to process a ticket is determinedbased on determining how many tickets have been processed during thepredetermined number of processor cycles. The sleep duration for theprocess is determined based on a number of tickets remaining to beprocessed for securing the spinlock for the process, and the timeduration to process a ticket.

In yet additional embodiments, the sleep duration for the process isalso based on a sleep overhead time.

In certain embodiments, the process sleeps, in response to the sleepduration for the process being greater than a predetermined thresholdamount of time.

In further embodiments, the process waits for the spinlock whilespinning, in response to the sleep duration for the process being lessthan or equal to the predetermined threshold amount of time.

BRIEF DESCRIPTION OF THE DRAWINGS

Referring now to the drawings in which like reference numbers representcorresponding parts throughout:

FIG. 1 illustrates a block diagram of computational device in which anadaptive ticket locking application is implemented, in accordance withcertain embodiments;

FIG. 2 illustrates a first flowchart to adjust a sleep duration for aprocess, based on an expected time for securing a spinlock, inaccordance with certain embodiments;

FIG. 3 illustrates a second flowchart to determine the sleep duration ofa process, based on an expected time for securing a spinlock, inaccordance with certain embodiments;

FIG. 4 illustrates a third flowchart to adjust a sleep duration for aprocess, based on an expected time for securing a spinlock, inaccordance with certain embodiments;

FIG. 5 illustrates a fourth flowchart to adjust a sleep duration for aprocess, based on an expected time for securing a spinlock, inaccordance with certain embodiments;

FIG. 6 illustrates a block diagram of a cloud computing environment, inaccordance with certain embodiments;

FIG. 7 illustrates a block diagram of further details of the cloudcomputing environment of FIG. 6, in accordance with certain embodiments;and

FIG. 8 illustrates a block diagram of a computational system that showscertain elements that may be included in the computational devicedescribed in FIG. 1, in accordance with certain embodiments.

DETAILED DESCRIPTION

In the following description, reference is made to the accompanyingdrawings which form a part hereof and which illustrate severalembodiments. It is understood that other embodiments may be utilized andstructural and operational changes may be made.

Locks to protect data structures and critical sections may be availablein programs that run in a computational device. While a lock is beingheld by a process, if other processes need to acquire the lock,typically the other processes may spin for the lock. While spinning forthe lock, the other processes perform no useful operations and waste CPUcycles. There is a need to minimize these wasted CPU cycles and allowother processes to run.

Certain operating systems provide a spinlock that allows a process to goto sleep if the lock cannot be obtained. The process spins for a shortamount of time and then sleeps if the process is unable to secure thelock. However, the duration of time the process should sleep is unknown.When the process that holds the lock exits the critical section andreleases the lock, the process wakes up any processes that are sleepingon the lock. The processes that wake up are able spin for the lock toacquire the lock. This may cause the release of the lock to take longer,impacting the process that was running with the lock and is nowattempting to release the lock.

Certain embodiments provide mechanisms in which a process spins for alock for a certain number of cycles. If the lock is not obtained, thenthe process calculates how long to sleep based on the rate at whichtickets are being served and how far away the ticket value of theprocess is from the current ticket value being processed. This isrepeated when the process wakes up, until the lock is obtained.

Certain embodiments provide an adaptive ticket locking mechanism tomaximize CPU usage, where a process that desires a lock is allowed tospin for a predetermined number of CPU cycles and if no lock is obtainedduring that time, a conservative determination is made of the amount oftime it is likely to take to secure a lock. This determination may bebased on the number of tickets served during the predetermined number ofCPU cycles, and how many tickets need to be processed before the ticketof the process can be processed. The process is allowed to sleep for theamount of time it is likely to take to secure the lock, after which theprocess attempts to secure the lock again. No extra overhead to wake upother processes is placed on the process that releases the lock.

Exemplary Embodiments

FIG. 1 illustrates a block diagram of a computing environment 100comprising a computational device 102. The computational device 102 maycomprise any suitable computational device including those presentlyknown in the art, such as, a personal computer, a workstation, a server,a mainframe, a hand held computer, a palm top computer, a telephonydevice, a network appliance, a blade computer, a processing device, acontroller, a storage server, a dual-server storage system, etc. Thecomputational device 102 may be included in any suitable network, suchas, a storage area network, a wide area network, the Internet, anintranet. In certain embodiments, the computational device 102 may be anelement in a cloud computing environment.

An adaptive ticket locking application 104 may execute in thecomputational device 102 that has one or more processors 105, where theadaptive ticket locking application 104 is an application that may beimplemented in software, firmware, hardware or any combination thereof.

A plurality of processes 106, 108, 110 may attempt to exclusivelyacquire a resource 112 by acquiring a spinlock 114 in the computationaldevice 102. The adaptive ticket locking application 104 providessequential ticket numbers to the processes 106, 108, 110 as theprocesses 106, 108, 110 first make a request to acquire the spinlock 114for exclusive access to the resource 112. For example, if the process106 is the first process to request the spinlock 114, the process 106may be provided a ticket number 116, where the ticket number 116 has avalue of one. If the process 108 is the second process to request thespinlock 114, the process 108 may be provided a ticket number 118, wherethe ticket number 118 has a value of two. If the process 110 is thethird process to request the spinlock 114, the process 110 may beprovided a ticket number 120, where the ticket number 120 has a value ofthree.

The adaptive ticket locking application 104 keeps track of the value ofthe ticket number indicating whose turn it is to acquire the spinlock114, in a data structure referred to as the current ticket number 122.Initially, the current ticket number 122 is one. Each time a processreleases the spinlock, the value of the current ticket number 122 isincremented by one, and the process that has the ticket number equal tothe value of the current ticket number 122 is then eligible to acquirethe spinlock 114.

In certain embodiments, when a process is unable to acquire the spinlock114 because the turn of the ticket number of the process has not yetarrived, based on the value of the current ticket number 122, theadaptive ticket locking application 104 computes a sleep duration 124,126, 128 for the process, where the computed sleep duration is anestimate of the time the process should sleep before the process wakesup and attempts to acquire the spinlock 114. As a result, cycles of theprocessors 105 may be used more efficiently, since the processes 106,108, 110 do not use the cycles of the processors 105 while the processes106, 108, 110 are sleeping.

A data structure referred to as “sleep overhead time” 130 stores the sumof the time for a process to be queued on a timer queue 132, and thetime for the queued process to be dispatched from the timer queue 132.The adaptive ticket locking application 104 uses the sleep overhead time130 while computing the sleep durations 124, 126, 128 to account for thetime needed for a process to be queued to the timer queue 132 and thetime needed for the queued process to be dispatched from the timer queue132. A data structure referred to as “sleep threshold” 134 stores theminimum computed sleep duration of a process at which the process isallowed to sleep. Placing a process in a sleep mode for a duration lessthan the sleep threshold 134 may not improve system performance becauseof the overhead time spent to put the process to sleep and then to wakeup the process.

FIG. 2 illustrates a first flowchart 200 to adjust a sleep duration fora process, based on an expected time for securing a spinlock, inaccordance with certain embodiments. The operations shown in FIG. 2 maybe performed under the control of the adaptive ticket lockingapplication 104 that executes in the computational device 102.

Control starts at block 202 in which for each process that is generatedor that has run a timeslice, a ticket number that is sequentiallygenerated is provided to the process, where block 204 shows that acurrent ticket number 122 denotes the ticket number that is authorizedto secure the spinlock 114 for the resource 112.

In parallel with the operations shown in blocks 202, 204 that are alsoindicated via braces 206, the operations indicated via braces 208 areperformed. The operations indicated via braces 208 are initiated inblock 210 in which a determination is made as to whether the ticketnumber of a process equals the current ticket number 122. If so (“Yes”branch 212) then the process obtains the spinlock 114 (at block 214).Control proceeds to block 216 in which the process runs a timeslice toaccess the resource 112. Once the timeslice is over, the processreleases (at block 218) the spinlock 114, and then the process waits forthe next timeslice or terminates. From block 218 control proceeds toblock 220 where the current ticket number 122 is incremented.

If at block 210 a determination is made that the ticket number of theprocess is not equal to the current ticket number 122 (“No” branch 222),then control proceeds to block 224 in which the adaptive ticket lockingapplication 104 determines the duration of time for which the processshould go to sleep (“sleep duration”), based on when the ticket numberof the process is likely to equal the current ticket number 122. Theprocess goes to sleep for the determined duration of time (at block226), and wakes up (at block 228) on its own after the elapse of thedetermined duration of time. From block 228 control proceeds to block210, where the process (after waking up) determines whether the ticketnumber of the process equals the current ticket number 122.

FIG. 3 illustrates a second flowchart 300 to determine the sleepduration for a process, based on an expected time for securing aspinlock, in accordance with certain embodiments. The operations shownin FIG. 3 may be performed under the control of the adaptive ticketlocking application 104 that executes in the computational device 102.

To determine the sleep duration for a process, the adaptive ticketlocking application 104 makes the process spin for n processor cyclesand determines (at block 302) how many tickets have been processedduring the n processor cycles. For example, the process spins for 2000processor cycles and determines that 4 tickets have been processed inthe 2000 processor cycles (i.e., the value of the current ticket number122 has advanced by 4 in the 2000 processor cycles).

Control proceeds to block 304, in which the average time (i.e., numberof processor cycles) of processing a ticket is calculated to be the “nprocessor cycles” divided by “the number of tickets processed in thenprocessor cycles”. For example, if 4 tickets have been processed in 2000processor cycles, then the average time for processing a ticket is 500processor cycles (as 2000 divided by 4 is 500).

From block 304 control proceeds to block 306 in which the sleep duration(i.e., the estimated time to sleep in processor cycles) for the processis computed to be the product of the number of tickets remaining to beprocessed for securing the spinlock and the average time for processinga ticket. For example, if the ticket number of the process is 30 and thecurrent ticket number is 20, then the number of tickets remaining to beprocessed for securing the spinlock is 10 (as 30−20=10). If the averagetime for processing a ticket has been computed as 500 processor cyclesin block 304, then the sleep time for the process is 5000 processorcycles (as 10×500=5000).

Therefore, FIG. 3 illustrates embodiments in which a process is made tospin for a predetermined number of processor cycles to estimate theaverage processing time for a ticket. Then an estimate is made of theamount of processor cycles to sleep, based on the how many tickets needto be processed before the turn of the process to acquire the spinlockis reached.

FIG. 4 illustrates a third flowchart 400 to adjust a sleep duration fora process, based on an expected time for securing a spinlock, inaccordance with certain embodiments. The operations shown in FIG. 4 maybe performed under the control of the adaptive ticket lockingapplication 104 that executes in the computational device 102.

Control starts at block 402 in which a variable “progress_time” is setto zero, where the variable “progress_time” denotes the number ofprocessing cycles that have elapsed. It should be noted that time may bemeasured in number of processor cycles or via some other unit, such asseconds, milliseconds, microseconds, etc. Control proceeds to block 404in which the adaptive ticket locking application 104 determines for aprocess (e.g. process 106) whether the “ticket number” 116 for theprocess 106 equals the “current ticket number” 122. If so (“yes” branch406), control proceeds to block 408 in which the process 106 acquiresthe spinlock 114 for accessing the resource 112.

If at block 404 the adaptive ticket locking application 104 determinesthat the “ticket number” 116 for the process 106 does not equal the“current ticket number” 122 (“No” branch 410), then control proceeds toblock 412 in which a variable “last_ticket” is set to the “currentticket number” 122, and the process 106 is made to spin for n cycles (atblock 414).

Control proceeds to block 416 in which a determination is made as towhether the “ticket number” 116 for the process 106 equals the “currentticket number” 122. If so (“yes” branch 418), control proceeds to block420 in which the process 106 acquires the spinlock 114 for accessing theresource 112.

If at block 416 a determination that the “ticket number” 116 for theprocess 106 does not equal (“no” branch 422) the “current ticket number”122, then control proceeds to block 424 in which the variable“ticket_progress” is set to the difference between the “current ticketnumber” 122 and the “last_ticket”. The “ticket_progress” indicates howmany tickets have been processed while the spinning for n cycles (shownin block 414) was being performed.

From block 424 control proceeds to block 426 in which the variable“ticket_delta” is set to be the difference of “ticket number” 116 of theprocess 106 and the “current ticket number” 122, where ticket_deltaindicates how many tickets need to be processed before the turn of theprocess 106 is reached to secure the spinlock 114.

Control proceeds to block 428 in which the variable “progress_time” isincremented by n to indicate the completion of the spinning for n cyclesstarted at block 414. The progress_time indicates the number ofprocessor cycles the process 106 has been spinning.

At block 430, a determination is made as to whether the variable“ticket_progress” is greater than zero (i.e., one or more tickets havebeen processed during the n cycles during which the process 106 wasspinning). If so (“Yes” branch 432), the expected_arival_time is set tobe the product of (ticket_delta/ticket_progress) and the progress_time,and then the progress_time is set to zero (at block 434).

If at block 430 a determination is made that ticket_progress is notgreater than zero (“No” branch 436) then control proceeds to block 438where the expected_arrival_time is set to the product of theticket_delta and the progress_time (i.e., when no tickets get processedin the n cycles, then it is empirically determined that each ticketwould on an average take at least the progress_time amount of time torun, and the expected_arrival_time is computed based on the number oftickets remaining to be processed and the time to process each ticket

From blocks 434 and block 438 control proceed to block 440 in which the“computed sleep duration” 124 is computed to be the difference betweenthe expected_arrival_time and the “sleep overhead time” 130, where thesleep overhead time 130 is the time needed to queue a process to thetimer queue 132 and the time needed to dispatch the queued process fromthe timer queue 132. A determination is made (at block 442) if the“computed sleep duration” 124 is greater than the “sleep threshold”, andif so (“yes” branch 444), the process 106 is made to sleep for the“computed sleep duration” 124 (at block 446) and control returns toblock 402. If at block 442, the “computed sleep duration” is not greaterthan the sleep_threshold (“no” branch 448), then the process waits (atblock 450) for the spinlock 114 and the control returns to block 404.

Therefore, in FIG. 4, a process is made to sleep only if the computedsleep duration 124 is greater than the sleep threshold 134, in order toavoid the overhead of putting a process to sleep and waking up theprocess. For example, a sleep threshold 134 may be set to 1 millisecond(or a predetermined number of processor cycles) and until the calculatedsleep duration 124 is at least 1 millisecond, the process 106 is notmade to sleep. Additionally, the computed sleep duration 124 is theestimated time remaining to secure the ticket adjusted for a sleepoverhead time to avoid the overhead time for adding the process to aqueue and removing from the process from the queue.

It should be noted that FIG. 4 shows one embodiment for determining thecomputed sleep duration 124, and other embodiments may determine thecomputed sleep duration 124 via other mechanisms.

FIG. 5 illustrates a fourth flowchart 500 to adjust a sleep duration fora process, based on an expected time for securing a spinlock, inaccordance with certain embodiments. The operations shown in FIG. 5 maybe performed under the control of the adaptive ticket lockingapplication 104 that executes in the computational device 102.

Control starts at block 502 in which a computational device 102maintains (i.e., stores in a data structure and updates the datastructure as necessary) a spinlock 114 for exclusive access of aresource 112 by a process of a plurality of processes 106, 108, 110. Forthe purposes of this disclosure the term processes includes threads andother similar constructs. Control proceeds to block 504 in which adetermination is made as to whether the turn for securing the spinlock114 has arrived for the process. In response to determining by theprocess that a turn for securing the spinlock has not arrived for theprocess (“No” branch 506), a sleep duration is determined (at block 508)for the process, and the process sleeps (at block 510) for the sleepduration, prior to making a next attempt to secure the spinlock 114 byreturning to block 504.

In response to determining (at block 504) by the process that a turn forsecuring the spinlock 114 has arrived for the process (“Yes” branch 512)control proceeds to block 514 where the process secures the spinlock114.

Therefore, FIG. 1-5 illustrate certain embodiments in which a sleepduration 124 is computed for a process 106 that is attempting to acquirea spinlock, instead of continuously spinning and wasting processorcycles. The process 106 is made to sleep for the sleep duration 124prior to waking up and attempting to acquire the spinlock 114 onceagain. The sleep duration 124 for the process 106 is based on when theprocess 106 is likely to secure the spinlock 114, based on a ticketnumber 116 of the process 106 and the current ticket number 122 that isbeing processed. In certain embodiments, the process 106 undergoesspinning for a predetermined number of processor cycles (e.g., nprocessor cycles) and a determination is made of how many tickets havebeen processed during the predetermined number of processor cycles. Anaverage time duration to process a ticket is determined based ondetermining how many tickets have been processed during thepredetermined number of processor cycles. The sleep duration for theprocess 106 is determined based on a number of tickets remaining to beprocessed for securing the spinlock for the process 106 and the averagetime duration to process a ticket.

In yet additional embodiments, the sleep duration for the process 106 isalso based on a sleep overhead time 130. In certain embodiments, theprocess 106 sleeps, in response to the computed sleep duration 124 forthe process 106 being greater than a predetermined threshold amount oftime (“sleep threshold” 134). In further embodiments, the process 106waits for the spinlock 114 while spinning, in response to the calculatedsleep duration 124 for the process 106 being less than or equal to thepredetermined threshold amount of time.

Therefore, FIG. 1-5 illustrate certain embodiments for adjusting thesleep duration of a process based on the expected time that is remainingto secure the spinlock for exclusive access of a resource.

Cloud Computing Environment

Cloud computing is a model for enabling convenient, on-demand networkaccess to a shared pool of configurable computing resources (e.g.,networks, servers, storage, applications, and services) that can berapidly provisioned and released with minimal management effort orservice provider interaction.

Referring now to FIG. 6, an illustrative cloud computing environment 50is depicted. As shown, cloud computing environment 50 comprises one ormore cloud computing nodes 10 with which local computing devices used bycloud consumers, such as, for example, personal digital assistant (PDA)or cellular telephone 54A, desktop computer 54B, laptop computer 54C,and/or automobile computer system 54N may communicate. Nodes 10 maycommunicate with one another. They may be grouped (not shown) physicallyor virtually, in one or more networks, such as Private, Community,Public, or Hybrid clouds as described hereinabove, or a combinationthereof. This allows cloud computing environment 50 to offerinfrastructure, platforms and/or software as services for which a cloudconsumer does not need to maintain resources on a local computingdevice. It is understood that the types of computing devices 54A-N shownin FIG. 6 are intended to be illustrative only and that computing nodes10 and cloud computing environment 50 can communicate with any type ofcomputerized device over any type of network and/or network addressableconnection (e.g., using a web browser).

Referring now to FIG. 7, a set of functional abstraction layers providedby cloud computing environment 50 (FIG. 6) is shown. It should beunderstood in advance that the components, layers, and functions shownin FIG. 7 are intended to be illustrative only and embodiments of theinvention are not limited thereto.

Hardware and software layer 60 includes hardware and softwarecomponents. Examples of hardware components include mainframes, in oneexample IBM zSeries* systems; RISC (Reduced Instruction Set Computer)architecture based servers, in one example IBM pSeries* systems; IBMxSeries* systems; IBM BladeCenter* systems; storage devices; networksand networking components. Examples of software components includenetwork application server software, in one example IBM WebSphere*application server software; and database software, in one example IBMDB2* database software. * IBM, zSeries, pSeries, xSeries, BladeCenter,WebSphere, and DB2 are trademarks of International Business MachinesCorporation registered in many jurisdictions worldwide.

Virtualization layer 62 provides an abstraction layer from which thefollowing examples of virtual entities may be provided: virtual servers;virtual storage; virtual networks, including virtual private networks;virtual applications and operating systems; and virtual clients.

In one example, management layer 64 may provide the functions describedbelow. Resource provisioning provides dynamic procurement of computingresources and other resources that are utilized to perform tasks withinthe cloud computing environment. Metering and Pricing provide costtracking as resources are utilized within the cloud computingenvironment, and billing or invoicing for consumption of theseresources. In one example, these resources may comprise applicationsoftware licenses. Security provides identity verification for cloudconsumers and tasks, as well as protection for data and other resources.User portal provides access to the cloud computing environment forconsumers and system administrators. Service level management providescloud computing resource allocation and management such that requiredservice levels are met. Service Level Agreement (SLA) planning andfulfillment provide pre-arrangement for, and procurement of, cloudcomputing resources for which a future requirement is anticipated inaccordance with an SLA.

Workloads layer 66 provides examples of functionality for which thecloud computing environment may be utilized. Examples of workloads andfunctions which may be provided from this layer include: mapping andnavigation; software development and lifecycle management; virtualclassroom education delivery; data analytics processing; transactionprocessing; and the spin duration determination and spinlock acquisition68 as shown in FIGS. 1-6.

Additional Embodiment Details

The described operations may be implemented as a method, apparatus orcomputer program product using standard programming and/or engineeringtechniques to produce software, firmware, hardware, or any combinationthereof. Accordingly, aspects of the embodiments may take the form of anentirely hardware embodiment, an entirely software embodiment (includingfirmware, resident software, micro-code, etc.) or an embodimentcombining software and hardware aspects that may all generally bereferred to herein as a “circuit,” “module” or “system.” Furthermore,aspects of the embodiments may take the form of a computer programproduct. The computer program product may include a computer readablestorage medium (or media) having computer readable program instructionsthereon for causing a processor to carry out aspects of the presentembodiments.

The computer readable storage medium can be a tangible device that canretain and store instructions for use by an instruction executiondevice. The computer readable storage medium may be, for example, but isnot limited to, an electronic storage device, a magnetic storage device,an optical storage device, an electromagnetic storage device, asemiconductor storage device, or any suitable combination of theforegoing. A non-exhaustive list of more specific examples of thecomputer readable storage medium includes the following: a portablecomputer diskette, a hard disk, a random access memory (RAM), aread-only memory (ROM), an erasable programmable read-only memory (EPROMor Flash memory), a static random access memory (SRAM), a portablecompact disc read-only memory (CD-ROM), a digital versatile disk (DVD),a memory stick, a floppy disk, a mechanically encoded device such aspunch-cards or raised structures in a groove having instructionsrecorded thereon, and any suitable combination of the foregoing. Acomputer readable storage medium, as used herein, is not to be construedas being transitory signals per se, such as radio waves or other freelypropagating electromagnetic waves, electromagnetic waves propagatingthrough a waveguide or other transmission media (e.g., light pulsespassing through a fiber-optic cable), or electrical signals transmittedthrough a wire.

Computer readable program instructions described herein can bedownloaded to respective computing/processing devices from a computerreadable storage medium or to an external computer or external storagedevice via a network, for example, the Internet, a local area network, awide area network and/or a wireless network. The network may comprisecopper transmission cables, optical transmission fibers, wirelesstransmission, routers, firewalls, switches, gateway computers and/oredge servers. A network adapter card or network interface in eachcomputing/processing device receives computer readable programinstructions from the network and forwards the computer readable programinstructions for storage in a computer readable storage medium withinthe respective computing/processing device.

Computer readable program instructions for carrying out operations ofthe present embodiments may be assembler instructions,instruction-set-architecture (ISA) instructions, machine instructions,machine dependent instructions, microcode, firmware instructions,state-setting data, or either source code or object code written in anycombination of one or more programming languages, including an objectoriented programming language such as Smalltalk, C++ or the like, andconventional procedural programming languages, such as the “C”programming language or similar programming languages. The computerreadable program instructions may execute entirely on the user'scomputer, partly on the user's computer, as a stand-alone softwarepackage, partly on the user's computer and partly on a remote computeror entirely on the remote computer or server. In the latter scenario,the remote computer may be connected to the user's computer through anytype of network, including a local area network (LAN) or a wide areanetwork (WAN), or the connection may be made to an external computer(for example, through the Internet using an Internet Service Provider).In some embodiments, electronic circuitry including, for example,programmable logic circuitry, field-programmable gate arrays (FPGA), orprogrammable logic arrays (PLA) may execute the computer readableprogram instructions by utilizing state information of the computerreadable program instructions to personalize the electronic circuitry,in order to perform aspects of the present embodiments.

Aspects of the present embodiments are described herein with referenceto flowchart illustrations and/or block diagrams of methods, apparatus(systems), and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer readable program instructions.

These computer readable program instructions may be provided to aprocessor of a general purpose computer, special purpose computer, orother programmable data processing apparatus to produce a machine, suchthat the instructions, which execute via the processor of the computeror other programmable data processing apparatus, create means forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks. These computer readable program instructionsmay also be stored in a computer readable storage medium that can directa computer, a programmable data processing apparatus, and/or otherdevices to function in a particular manner, such that the computerreadable storage medium having instructions stored therein comprises anarticle of manufacture including instructions which implement aspects ofthe function/act specified in the flowchart and/or block diagram blockor blocks.

The computer readable program instructions may also be loaded onto acomputer, other programmable data processing apparatus, or other deviceto cause a series of operational steps to be performed on the computer,other programmable apparatus or other device to produce a computerimplemented process, such that the instructions which execute on thecomputer, other programmable apparatus, or other device implement thefunctions/acts specified in the flowchart and/or block diagram block orblocks.

The flowchart and block diagrams in the figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods, and computer program products according to variousembodiments of the present invention. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof instructions, which comprises one or more executable instructions forimplementing the specified logical function(s). In some alternativeimplementations, the functions noted in the block may occur out of theorder noted in the figures. For example, two blocks shown in successionmay, in fact, be executed substantially concurrently, or the blocks maysometimes be executed in the reverse order, depending upon thefunctionality involved. It will also be noted that each block of theblock diagrams and/or flowchart illustration, and combinations of blocksin the block diagrams and/or flowchart illustration, can be implementedby special purpose hardware-based systems that perform the specifiedfunctions or acts or carry out combinations of special purpose hardwareand computer instruction.

FIG. 8 illustrates a block diagram that shows certain elements that maybe included in the computational device 102, in accordance with certainembodiments. The system 800 may include a circuitry 802 that may incertain embodiments include at least a processor 804. The system 800 mayalso include a memory 806 (e.g., a volatile memory device), and storage808. The storage 808 may include a non-volatile memory device (e.g.,EEPROM, ROM, PROM, flash, firmware, programmable logic, etc.), magneticdisk drive, optical disk drive, tape drive, etc. The storage 808 maycomprise an internal storage device, an attached storage device and/or anetwork accessible storage device. The system 800 may include a programlogic 810 including code 812 that may be loaded into the memory 806 andexecuted by the processor 804 or circuitry 802. In certain embodiments,the program logic 810 including code 812 may be stored in the storage808. In certain other embodiments, the program logic 810 may beimplemented in the circuitry 802. One or more of the components in thesystem 800 may communicate via a bus or via other coupling or connection814. Therefore, while FIG. 8 shows the program logic 810 separately fromthe other elements, the program logic 810 may be implemented in thememory 806 and/or the circuitry 802.

Certain embodiments may be directed to a method for deploying computinginstruction by a person or automated processing integratingcomputer-readable code into a computing system, wherein the code incombination with the computing system is enabled to perform theoperations of the described embodiments.

The terms “an embodiment”, “embodiment”, “embodiments”, “theembodiment”, “the embodiments”, “one or more embodiments”, “someembodiments”, and “one embodiment” mean “one or more (but not all)embodiments of the present invention(s)” unless expressly specifiedotherwise.

The terms “including”, “comprising”, “having” and variations thereofmean “including but not limited to”, unless expressly specifiedotherwise.

The enumerated listing of items does not imply that any or all of theitems are mutually exclusive, unless expressly specified otherwise.

The terms “a”, “an” and “the” mean “one or more”, unless expresslyspecified otherwise.

Devices that are in communication with each other need not be incontinuous communication with each other, unless expressly specifiedotherwise. In addition, devices that are in communication with eachother may communicate directly or indirectly through one or moreintermediaries.

A description of an embodiment with several components in communicationwith each other does not imply that all such components are required. Onthe contrary a variety of optional components are described toillustrate the wide variety of possible embodiments of the presentinvention.

Further, although process steps, method steps, algorithms or the likemay be described in a sequential order, such processes, methods andalgorithms may be configured to work in alternate orders. In otherwords, any sequence or order of steps that may be described does notnecessarily indicate a requirement that the steps be performed in thatorder. The steps of processes described herein may be performed in anyorder practical. Further, some steps may be performed simultaneously.

When a single device or article is described herein, it will be readilyapparent that more than one device/article (whether or not theycooperate) may be used in place of a single device/article. Similarly,where more than one device or article is described herein (whether ornot they cooperate), it will be readily apparent that a singledevice/article may be used in place of the more than one device orarticle or a different number of devices/articles may be used instead ofthe shown number of devices or programs. The functionality and/or thefeatures of a device may be alternatively embodied by one or more otherdevices which are not explicitly described as having suchfunctionality/features. Thus, other embodiments of the present inventionneed not include the device itself.

At least certain operations that may have been illustrated in thefigures show certain events occurring in a certain order. In alternativeembodiments, certain operations may be performed in a different order,modified or removed. Moreover, steps may be added to the above describedlogic and still conform to the described embodiments. Further,operations described herein may occur sequentially or certain operationsmay be processed in parallel. Yet further, operations may be performedby a single processing unit or by distributed processing units.

The foregoing description of various embodiments of the invention hasbeen presented for the purposes of illustration and description. It isnot intended to be exhaustive or to limit the invention to the preciseform disclosed. Many modifications and variations are possible in lightof the above teaching. It is intended that the scope of the invention belimited not by this detailed description, but rather by the claimsappended hereto. The above specification, examples and data provide acomplete description of the manufacture and use of the composition ofthe invention. Since many embodiments of the invention can be madewithout departing from the spirit and scope of the invention, theinvention resides in the claims hereinafter appended.

What is claimed is:
 1. A method, comprising: maintaining, by acomputational device, a spinlock for exclusive access of a resource by aprocess of a plurality of processes; and in response to determining bythe process that a turn indicated by a ticket number of the process forsecuring the spinlock has not arrived for the process, determining asleep duration for the process based on a number of tickets remaining tobe processed for securing the spinlock and an average time duration toprocess a ticket; and entering, by the process, a sleep mode the sleepduration.
 2. The method of claim 1, wherein the sleep duration isdetermined prior to making a next attempt to secure the spinlock.
 3. Themethod of claim 1, wherein the a sleep duration for the process isdetermined based on computing a product of a number of tickets remainingto be processed for securing the spinlock for the process, and anaverage time duration to process a ticket.
 4. The method of claim 1,wherein the determining of the sleep duration for the process furthercomprises: spinning the process for a predetermined number of processorcycles and determining how many tickets have been processed during thepredetermined number of processor cycles; and determining the averagetime duration to process a ticket based on determining how many ticketshave been processed during the predetermined number of processor cycles.5. The method of claim 1, wherein the plurality of processes areassigned sequential ticket numbers.
 6. The method of claim 5, whereinthe plurality of processes secure the spinlock in sequence, based on thesequentially assigned ticket numbers, and wherein the process ispermitted to enter a critical section is which a shared resource isaccessed, in response to arriving of the turn indicated by the ticketnumber of the process.
 7. A system, comprising: a memory; a processorcoupled to the memory, wherein the processor performs operations, theoperations comprising: maintaining a spinlock for exclusive access of aresource by a process of a plurality of processes; and in response todetermining by the process that a turn indicated by a ticket number ofthe process for securing the spinlock has not arrived for the process,determining a sleep duration for the process based on a number oftickets remaining to be processed for securing the spinlock and anaverage time duration to process a ticket; and entering, by the process,a sleep mode the sleep duration.
 8. The system of claim 7, wherein thesleep duration is determined prior to making a next attempt to securethe spinlock.
 9. The system of claim 7, wherein the a sleep duration forthe process is determined based on computing a product of a number oftickets remaining to be processed for securing the spinlock for theprocess, and an average time duration to process a ticket.
 10. Thesystem of claim 7, wherein the determining of the sleep duration for theprocess further comprises: spinning the process for a predeterminednumber of processor cycles and determining how many tickets have beenprocessed during the predetermined number of processor cycles; anddetermining the average time duration to process a ticket based ondetermining how many tickets have been processed during thepredetermined number of processor cycles.
 11. The system of claim 7,wherein the plurality of processes are assigned sequential ticketnumbers.
 12. The system of claim 11, wherein the plurality of processessecure the spinlock in sequence, based on the sequentially assignedticket numbers, and wherein the process is permitted to enter a criticalsection is which a shared resource is accessed, in response to arrivingof the turn indicated by the ticket number of the process.
 13. Acomputer program product, the computer program product comprising acomputer readable storage medium having computer readable program codeembodied therewith, the computer readable program code configured toperform operations, the operations comprising: maintaining a spinlockfor exclusive access of a resource by a process of a plurality ofprocesses; and in response to determining by the process that a turnindicated by a ticket number of the process for securing the spinlockhas not arrived for the process, determining a sleep duration for theprocess based on a number of tickets remaining to be processed forsecuring the spinlock and an average time duration to process a ticket;and entering, by the process, a sleep mode the sleep duration.
 14. Thecomputer program product of claim 13, wherein the sleep duration isdetermined prior to making a next attempt to secure the spinlock. 15.The computer program product of claim 13, wherein the a sleep durationfor the process is determined based on computing a product of a numberof tickets remaining to be processed for securing the spinlock for theprocess, and an average time duration to process a ticket.
 16. Thecomputer program product of claim 13, wherein the determining of thesleep duration for the process further comprises: spinning the processfor a predetermined number of processor cycles and determining how manytickets have been processed during the predetermined number of processorcycles; and determining the average time duration to process a ticketbased on determining how many tickets have been processed during thepredetermined number of processor cycles.
 17. The computer programproduct of claim 13, wherein the plurality of processes are assignedsequential ticket numbers.
 18. The computer program product of claim 17,wherein the plurality of processes secure the spinlock in sequence,based on the sequentially assigned ticket numbers, and wherein theprocess is permitted to enter a critical section is which a sharedresource is accessed, in response to arriving of the turn indicated bythe ticket number of the process.